package com.ruoyi.restaurant.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.restaurant.domain.SysJiagong;
import com.ruoyi.restaurant.vo.DashboardVo;
import com.ruoyi.restaurant.vo.PriceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.restaurant.mapper.SysCategoryMapper;
import com.ruoyi.restaurant.domain.SysCategory;
import com.ruoyi.restaurant.service.ISysCategoryService;

/**
 * 餐品种类列表Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-04-13
 */
@Service
public class SysCategoryServiceImpl implements ISysCategoryService 
{
    @Autowired
    private SysCategoryMapper sysCategoryMapper;

    /**
     * 查询餐品种类列表
     * 
     * @param categoryId 餐品种类列表主键
     * @return 餐品种类列表
     */
    @Override
    public SysCategory selectSysCategoryByCategoryId(Long categoryId)
    {
        return sysCategoryMapper.selectSysCategoryByCategoryId(categoryId);
    }

    /**
     * 查询餐品种类列表列表
     * 
     * @param sysCategory 餐品种类列表
     * @return 餐品种类列表
     */
    @Override
    public List<SysCategory> selectSysCategoryList(SysCategory sysCategory)
    {
        return sysCategoryMapper.selectSysCategoryList(sysCategory);
    }

    /**
     * 新增餐品种类列表
     * 
     * @param sysCategory 餐品种类列表
     * @return 结果
     */
    @Override
    public int insertSysCategory(SysCategory sysCategory)
    {
        return sysCategoryMapper.insertSysCategory(sysCategory);
    }

    /**
     * 修改餐品种类列表
     * 
     * @param sysCategory 餐品种类列表
     * @return 结果
     */
    @Override
    public int updateSysCategory(SysCategory sysCategory)
    {
        return sysCategoryMapper.updateSysCategory(sysCategory);
    }

    /**
     * 批量删除餐品种类列表
     * 
     * @param categoryIds 需要删除的餐品种类列表主键
     * @return 结果
     */
    @Override
    public int deleteSysCategoryByCategoryIds(Long[] categoryIds)
    {
        return sysCategoryMapper.deleteSysCategoryByCategoryIds(categoryIds);
    }

    /**
     * 删除餐品种类列表信息
     * 
     * @param categoryId 餐品种类列表主键
     * @return 结果
     */
    @Override
    public int deleteSysCategoryByCategoryId(Long categoryId)
    {
        return sysCategoryMapper.deleteSysCategoryByCategoryId(categoryId);
    }

    /**
     * 各不同类型餐品在一周点餐中所带来的总体收益金额(参数：categoryNames)
     * @return 结果
     */
    @Override
    public List<PriceVo> countByCategoryNames(){
        List<SysCategory> categoryList = this.sysCategoryMapper.selectSysCategoryList(new SysCategory());
        List<PriceVo> priceVoList = new ArrayList<>();
        for(SysCategory category : categoryList){
            PriceVo priceVo = new PriceVo();
            float count = this.sysCategoryMapper.countByCategoryNames(category.getCategoryNames());
            String name = category.getCategoryNames();
            //priceVo.setValue(count);
            priceVo.setName(name);
            priceVoList.add(priceVo);
        }
        return priceVoList;
    }

}
